#ifndef DESIGNITEM_H
#define DESIGNITEM_H


#include <abstractmodelitem.h>


#include <datacontainer.h>


#include <QSharedData>
#include <QSharedDataPointer>
#include <QPointer>


class DesignItem : public AbstractModelItem
{
    Q_OBJECT

    class Data : public QSharedData
    {
    public:
        Data() {}
        Data(const Data& other) :
            QSharedData(other)
        {
            dataContainer = other.dataContainer;
        }

        QPointer<DataContainer> dataContainer;
    };


public:

    explicit DesignItem(QObject *parent = 0);
    explicit DesignItem(DataContainer* container, QObject *parent = 0);
    ~DesignItem();

    static DesignItem* fromData(DataContainer* container);

    virtual int fieldCount() const;
    virtual QVariant value(int field, int role) const;
    virtual bool setValue(int field, const QVariant &value, int role);
    virtual QVariant fieldName(int field) const;

    DataContainer* container() const;
    void setContainer(DataContainer* container);

    DesignItem* parentItem() const;

private:

    QSharedDataPointer<Data> d;

};

Q_DECLARE_METATYPE(DesignItem*)

#endif // DESIGNITEM_H
